<%@ page import="photobox.account.Notice; photobox.account.User" %>
<g:render template="../home/header" ></g:render>

<!--主体-->
<div  class="wid_1200 mTo_20">
    <div class="f_l">
        <div class="left_blk mBo_20 load_blk_ying">
            <div class="user_blk"><!--<div class="user_head"><img src="../${member?.photoImage}" alt="头像"></div>-->
                <g:if test="${session.userId}">
                    <div class="user_head">
                        <g:if test="${photobox.account.User.get(session.userId)?.photoImage}">
                            <img src="../${User.findById(session.userId)?.photoImage}"  alt="头像" />
                        </g:if>
                        <g:else>
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown"><img src="${resource(dir: '/assets/img', file: 'headp_140.jpg')}" alt="photobox" class="userPic"></a>
                        </g:else>
                    </div>
                </g:if>
            </div>
            <!--nav-->
            <div class="nav_left bor4" style=" height:108px;">
                <ul class="">
                    <li><g:link controller="member" action="browserHistory"><span class=" tubiao4 tubiao4_1">&nbsp;</span>我浏览的作品</g:link></li>
                    <li><g:link controller="member" action="purchasedPhoto"><span class=" tubiao4 tubiao4_2">&nbsp;</span>我购买的作品</g:link></li>
                </ul>
            </div>
            <!--/nav-->
        </div>
        <!--/用户简介-->
        <div class="left_blk pBo_20">
            <div class="sJiao"><div class="jiao1"></div></div>
            <div class="user_jianj">
                <p>${member?.presentation}</p>
            </div>
        </div>
    <!--/用户简介-->
    </div>

    <!--blk3-->
    <div class="blk3 f_r ">
        <!--我购买的作品-->
            <div class="crumbs mLe_20">
                <span><a href="/photobox/member/personCenter">个人信息</a></span><em class="tubiao2">&nbsp;</em><span>消息通知</span>
            </div>
            <!---->
            <input type="hidden" value="${max}" id="maxId" />
            <input type="hidden" value="${offset}" id="offsetId" />

            <div class="blk3_1" id="pic_con">
                %{--<div class="table_qu">--}%
                        %{--<g:each in="${notice}">--}%
                            %{--${it?.message}--}%
                        %{--</g:each>--}%

                    %{--</div>--}%
                <div class="bor1" style=" margin: 20px auto 0; width: 90%; border-bottom: none;">
                    <ul class="biao1" >
                        <div class="flow" ></div>
                    </ul>
                </div>

                    %{--<div class="table_qu">--}%
                        %{--<ul class="biao1" width="100%">--}%
                            %{--<g:each in="${Notice.findAllByUser(member)}">--}%
                                %{--<li><a href="javascript:;">--}%
                                    %{--<div class="biaocon f_l">--}%
                                        %{--<a href="javascript:;">--}%
                                        %{--${it.message}</a>--}%
                                    %{--</div>--}%
                                    %{--<div class="biaotime f_r">${it.dateCreated}</div>--}%
                                %{--</a></li>--}%
                            %{--</g:each>--}%
                        %{--</ul>--}%
                    %{--</div>--}%
            </div>
    </div>
</div>
<!--/主体-->
<script>
    Date.prototype.Format = function (fmt) {
        var o = {
            "M+": this.getMonth() + 1,
            "d+": this.getDate(),
            "h+": this.getHours(),
            "m+": this.getMinutes(),
            "s+": this.getSeconds(),
            "q+": Math.floor((this.getMonth() + 3) / 3),
            "S": this.getMilliseconds()
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    }

    var ajaxPhoto = function(max,offset){
        if($("#maxId").attr("name")){
            return;
        }
        $("#maxId").attr("name",'request');
        $.ajax({
            type:"POST",
            url:"<g:createLink controller='member' action='news'/>",
            data:{max:max,offset:offset,json:1},
            dataType:'json',
            beforeSend:function(){
            },
            success:function(data){
                $("#maxId").attr("name","");
                $('#maxId').val(data.max);
                $('#offsetId').val(data.offset);
                var d = data.notice;
                for(var i = 0 ; i < d.length ; i++){
                    var r=d[i];
                     var html = [];
                     html.push('<li id="contentU">')
                     html.push('<div  class="biaocon f_l" style="text-align: left;">'+ r.message + '</div>');
                     html.push('<div  class="biaotime f_r">' + new Date(r.dateCreated).Format("yyyy-MM-dd hh:mm:ss") + '</div>');
                     html.push('</li>');
                     $(".flow").append(html.join(' '));
                }
            },
            error: function (data, status, e)//服务器响应失败处理函数
            {
                alert(e);
            }
        });
    };
    $(document).ready(function(){
        //初始化数据
        ajaxPhoto(8,0);
        $(window).scroll(function(){
            // 被卷去的高度
            var scrollTop = document.body.scrollTop||document.documentElement.scrollTop;
            // 页面高度
            var pageHeight = $(document).height();
            // 可视区域高度
            var viewHeight = $(window).height();
            //alert(viewHeight);
            //当滚动到底部时
            if((scrollTop + viewHeight)>(pageHeight-20)){
                ajaxPhoto($('#maxId').val(),$('#offsetId').val());
            }
        });
    });
</script>
<g:render template="../home/footer" ></g:render>





